package com.example.fitnessapp.controller;

import com.example.fitnessapp.util.ApiResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/record")
@RequiredArgsConstructor
class RecordController {
    @PostMapping

    public ApiResponse<Void> addRecord(@RequestBody Map<String, Object> req) {
        // TODO: 调用 Service 新增打卡
        return ApiResponse.ok("打卡成功");
    }

    @GetMapping("/{userId}")
    public ApiResponse<List<Map<String, Object>>> listRecords(
            @PathVariable String userId,
            @RequestParam(required = false) String startDate,
            @RequestParam(required = false) String endDate) {
        // TODO: 调用 Service 查询记录
        List<Map<String, Object>> list = new ArrayList<>();
        Map<String, Object> rec = new HashMap<>();
        rec.put("recordId", "r001");
        rec.put("date", "2024-06-01");
        rec.put("steps", 12000);
        rec.put("heartRate", 80);
        rec.put("duration", 60);
        rec.put("calorie", 300);
        list.add(rec);
        return ApiResponse.ok("success", list);
    }
}
